package com.china08.yxyapi.repository.mg;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.entity.mg.sws.SwsArticle;

public interface SwsArticleRepository extends MongoRepository<SwsArticle, String> {

    SwsArticle findById(String id);

    // 获取orderNum最大的
    SwsArticle findTop1ByOwnerSchoolIdOrderByOrderNumDesc(String schoolId);

    List<SwsArticle> findBySection1Id(String section1Id);

    List<SwsArticle> findBySection2Id(String section2Id);

    Integer countByOwnerSchoolIdAndAuditStatus(String schoolId, Integer auditStatus);

    List<SwsArticle> findTop5ByOwnerSchoolIdAndSection1IdAndAuditStatus(String schoolId, String section1Id,
            Integer auditStatus, Sort sort);

    Page<SwsArticle> findByOwnerSchoolIdAndSection2IdAndAuditStatus(String schoolId, String section2Id,
            Integer auditStatus, Pageable pageable);

    List<SwsArticle> findTop8ByOwnerSchoolIdAndAuditStatusAndSection1IdOrderByPvDesc(String schoolId,
            Integer auditStatus, String section1Id);

    List<SwsArticle> findTop8ByOwnerSchoolIdAndAuditStatusOrderByPvDesc(String schoolId, Integer auditStatus);

    List<SwsArticle> findTop8ByOwnerSchoolIdAndAuditStatusAndSection2IdOrderByPvDesc(String schoolId,
            Integer auditStatus, String section2Id);

    Page<SwsArticle> findByOwnerSchoolId(String schoolId, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1Id(String schoolId, String sectionId, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndSection2Id(String schoolId, String section1Id,
            String section2Id, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndAuditStatus(String schoolId, String sectionId,
            Integer auditStatus, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndSection2IdAndAuditStatus(String schoolId, String section1Id,
            String section2Id, Integer auditStatus, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndSection2IdAndTitleContaining(String schoolId, String section1Id,
            String section2Id, String title, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndTitleContaining(String schoolId, String sectionId, String title,
            Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndAuditStatusAndTitleContaining(String schoolId, String sectionId,
            Integer AuditStatus, String title, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSection1IdAndSection2IdAndAuditStatusAndTitleContaining(String schoolId,
            String section1Id, String section2Id, Integer auditStatus, String title, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndAuditStatus(String schoolId, Integer auditStatus, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndAuditStatusAndTitleContaining(String schoolId, Integer auditStatus,
            String title, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndTitleContaining(String schoolId, String title, Pageable pageable);

    SwsArticle findTop1ByOwnerSchoolIdAndAuditStatusOrderByUpdateDateDesc(String schoolId, int i);

    SwsArticle findTop1ByOwnerSchoolIdAndAuditStatusOrderByPublishDateDesc(String schoolId, int i);

    SwsArticle findTop1ByOwnerSchoolIdAndAuditStatusOrderByShowDateDesc(String schoolId, int i);

    long countByOwnerSchoolIdAndAuditStatusAndIdNotNull(String schoolId, Integer auditStatus);

    List<SwsArticle> findTop6ByAuditStatusAndOwnerSchoolIdAndSection1IdNotAndRecommendOrderByShowDateDesc(int i,
            String schoolId, String sectionId, boolean recommend);

    Page<SwsArticle> findByOwnerSchoolIdAndSenderIdAndSection2Id(String schoolId, String senderId, String section2Id,
            Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSenderIdAndSection1Id(String schoolId, String senderId, String section1Id,
            Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSenderId(String schoolId, String senderId, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSenderIdAndSection2IdAndTitleContaining(String schoolId, String senderId,
            String section2Id, String title, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSenderIdAndSection1IdAndTitleContaining(String schoolId, String senderId,
            String section1Id, String title, Pageable pageable);

    Page<SwsArticle> findByOwnerSchoolIdAndSenderIdAndTitleContaining(String schoolId, String senderId, String title,
            Pageable pageable);

    List<SwsArticle> findTop5ByOwnerSchoolIdAndAuditStatusOrderByPublishDate(String schoolId, int i);

    Integer countByOwnerSchoolIdAndAuditStatusAndSection1IdIn(String schoolId, int i, List<String> section1List);

    Integer countByOwnerSchoolIdAndAuditStatusAndSection2IdIn(String schoolId, int i, List<String> section2List);

    List<SwsArticle> findTop5ByOwnerSchoolIdAndAuditStatusOrderByPublishDateDesc(String schoolId, int i);

    SwsArticle findTop1ByOwnerSchoolIdAndSection2IdAndAuditStatusAndIsStickyAndShowDateLessThanOrderByIsStickyAscShowDateDesc(
            String schoolId, String section2Id, Integer auditStatus, boolean b, Date showDate);

    SwsArticle findTop1ByOwnerSchoolIdAndSection2IdAndAuditStatusAndIsStickyOrderByIsStickyAscShowDateDesc(
            String schoolId, String section2Id, Integer auditStatus, boolean b);

    SwsArticle findTop1ByOwnerSchoolIdAndSection2IdAndAuditStatusAndIsStickyOrderByIsStickyAscShowDateAsc(
            String schoolId, String section2Id, Integer auditStatus, boolean b);

    SwsArticle findTop1ByOwnerSchoolIdAndSection2IdAndAuditStatusAndIsStickyAndShowDateGreaterThanOrderByIsStickyAscShowDateAsc(
            String schoolId, String section2Id, Integer auditStatus, boolean b, Date showDate);

    SwsArticle findTop1ByOwnerSchoolIdAndSection1IdAndAuditStatusAndIsStickyAndShowDateLessThanOrderByIsStickyAscShowDateDesc(
            String schoolId, String section1Id, Integer auditStatus, boolean b, Date showDate);

    SwsArticle findTop1ByOwnerSchoolIdAndSection1IdAndAuditStatusAndIsStickyOrderByIsStickyAscShowDateDesc(
            String schoolId, String section1Id, Integer auditStatus, boolean b);

    SwsArticle findTop1ByOwnerSchoolIdAndSection1IdAndAuditStatusAndIsStickyAndShowDateGreaterThanOrderByIsStickyAscShowDateAsc(
            String schoolId, String section1Id, Integer auditStatus, boolean b, Date showDate);

    SwsArticle findTop1ByOwnerSchoolIdAndSection1IdAndAuditStatusAndIsStickyOrderByIsStickyAscShowDateAsc(
            String schoolId, String section1Id, Integer auditStatus, boolean b);

    SwsArticle findTop1ByOwnerSchoolIdAndAuditStatusAndShowDateGreaterThanOrderByShowDateAsc(String schoolId,
            Integer auditStatus, Date showDate);

    SwsArticle findTop1ByOwnerSchoolIdAndAuditStatusAndShowDateLessThanOrderByShowDateDesc(String schoolId,
            Integer auditStatus, Date showDate);

}
